package com.huawei.gamebox.service.welfare.campaign.card;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.service.common.cardkit.card.HorizonBaseCard;
import com.huawei.gamebox.service.common.cardkit.card.HorizonBaseCard.a.b;
import com.huawei.gamebox.service.welfare.campaign.bean.CampaignSildeCardBean;
import o.azb;
import o.chc;
import o.exp$a;
import o.exp.d;
import o.exp.j;
import o.fbu;

public class CampaignListSideslipCard extends HorizonBaseCard {
    private int ˋ;

    class a extends com.huawei.gamebox.service.common.cardkit.card.HorizonBaseCard.a {
        final /* synthetic */ CampaignListSideslipCard ˊ;

        class e extends b {
            private View ʼॱ;
            private View ʽॱ;
            final /* synthetic */ a ॱˋ;
            private View ᐝॱ;

            e(a aVar, View view) {
                this.ॱˋ = aVar;
                super(aVar, view);
                this.ᐝॱ = view.findViewById(d.ॱˌ);
                RelativeLayout relativeLayout = (RelativeLayout) this.ᐝॱ.findViewById(d.ˌॱ);
                LayoutParams layoutParams = (LayoutParams) relativeLayout.getLayoutParams();
                layoutParams.topMargin = 1;
                relativeLayout.setLayoutParams(layoutParams);
                this.ʼॱ = view.findViewById(d.ॱᐧ);
                this.ʽॱ = view.findViewById(d.ॱˑ);
            }
        }

        private a(CampaignListSideslipCard campaignListSideslipCard) {
            this.ˊ = campaignListSideslipCard;
            super(campaignListSideslipCard);
        }

        public b ॱ(ViewGroup viewGroup, int i) {
            return new e(this, LayoutInflater.from(viewGroup.getContext()).inflate(j.ᐝˊ, viewGroup, false));
        }

        public void ˋ(b bVar, int i) {
            e eVar = (e) bVar;
            CampaignSildeCardBean campaignSildeCardBean = (CampaignSildeCardBean) this.ˊ.ˌ();
            int size = campaignSildeCardBean.ᐝ().size();
            int i2 = i * 3;
            for (int i3 = 0; i3 < 3; i3++) {
                View view;
                if (i3 == 0) {
                    view = (ViewGroup) eVar.ᐝॱ;
                } else if (i3 == 1) {
                    view = (ViewGroup) eVar.ʼॱ;
                } else {
                    view = (ViewGroup) eVar.ʽॱ;
                }
                LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) view.getLayoutParams();
                if (layoutParams == null) {
                    view.setLayoutParams(new LinearLayout.LayoutParams(this.ˊ.ˋ, -2));
                } else {
                    layoutParams.width = this.ˊ.ˋ;
                }
                int i4 = i2 + i3;
                if (i4 < size) {
                    view.setVisibility(0);
                    fbu o_fbu = new fbu(this.ˊ.ʼॱ, false);
                    o_fbu.ˏ(view);
                    CardBean cardBean = (CardBean) campaignSildeCardBean.ᐝ().get(i4);
                    cardBean.ˋˋ(campaignSildeCardBean.ॱˉ());
                    o_fbu.ˏ(cardBean);
                    o_fbu.ॱ(this.ˊ.ॱ);
                    if (i3 == 2 || i4 == size - 1) {
                        view.findViewById(d.ʽॱ).setVisibility(4);
                    }
                } else if (i == 0) {
                    view.setVisibility(8);
                } else {
                    view.setVisibility(4);
                }
            }
        }

        public int ˏ() {
            CardBean ˌ = this.ˊ.ˌ();
            if (ˌ instanceof CampaignSildeCardBean) {
                CampaignSildeCardBean campaignSildeCardBean = (CampaignSildeCardBean) ˌ;
                if (campaignSildeCardBean.ᐝ() != null) {
                    return Double.valueOf(Math.ceil(((double) campaignSildeCardBean.ᐝ().size()) / 3.0d)).intValue();
                }
            }
            return 0;
        }
    }

    public CampaignListSideslipCard(Context context) {
        super(context);
        ॱˊ();
    }

    public void ʻ() {
        this.ˏ = chc.ˋॱ();
    }

    private void ॱˊ() {
        int ˊ = azb.ˊ(this.ʼॱ) + this.ʼॱ.getResources().getDimensionPixelSize(exp$a.ˊॱ);
        this.ˋ = ˊ + ((((azb.ॱ(this.ʼॱ) - this.ˊ.ॱ()) - (this.ˏ * ˊ)) - (this.ˊ.ॱॱ() * (this.ˏ + 2))) / this.ˏ);
    }

    public androidx.recyclerview.widget.RecyclerView.a ˊॱ() {
        return new a();
    }
}
